There are several basic things you can do from a script, including:
- getting information about currently defined targets or realms
- getting a list (or partial list) of users or groups from a specific target
- creating a new realm, user, or group
- modifying the attributes of an existing realm, user, or group
- deleting a realm, user, or group
The most commonly used feature here is the ability to automatically add a user and give them access to a set or realms or groups. For example, you could add a user to WebSentinel from common CGI products such as WebSiphon, Lasso, or Tango when a user submitted a form, or role your own simple AppleScript CGI. You could also create a script that would generate reports, detailing which users had access to which areas of the site, for example.
In order to start WebSentinel scripting, it's important to understand the basics of how WebSentinel keeps track of information. Each item (whether it's a target, realm, user, or group) has a unique id that can be used to reference that item. When you request a list of realms, you'll notice that each realm object contains a unique number in addition to the realm name, match string, etc. In a script, you can keep track of this unique identifier and use it when calling other WebSentinel functions, such as changing a realm's attributes, or adding a user to a realm.
Additionally, any function that accepts a realm id or target id can also accept a realm name or target name. Note that this is slower than sending an id, however, since WebSentinel must do the conversion for you.
Examples
There are several simple examples on how to script WebSentinel using a variety of applications. Until there is sufficient documentation, the best way to understand the scripting capabilities is probably to poke around in the Script Editor. The following is a description of the items you may wish to look.
AppleScript
- Add User example: Demonstrates how to add a user to WebSentinel with access to a realm.
- WebSentinel Dictionary: A copy of WebSentinel Gateway's dictionary. This is the same as opening WebSentinel Gateway from the Open Dictionary menu item in Script Editor.
WebSiphon
- sentinel_functions.t: An include file for use with WebSiphon 1.5 or later that simplifies communicating with WebSentinel. The file contains WebSiphon functions you can call directly from your WebSiphon templates. Just include the file in your template, or drop the sentinel_functions.t file into your script libraries folder.
- sentinel_example.t: A simple WebSiphon template that shows more involved interaction with WebSentinel by reproducing the "Lookup user" feature found in WebSentinel Admin and the web-based admin. Just drop this file in your Templates folder or anywhere in your web server and access it from a browser.
Frontier
- WebSentinel Frontier glue: A Frontier glue file for use with WebSentinel. Double-click on it to install it into your copy of Frontier.
- Frontier Menu Sharing support: Double-click on this file to install a default menubar into Frontier. When Frontier is running you will have access to a special "Scripts" menu from within WebSentinel Admin.
Tango
- Two simple example query documents that demonstrate adding a realm from Tango and adding a user via a simple form. Please read the "Readme" action when opening the Tango documents in Tango Editor for details. This files were created with Tango 2.x, and may require modification to work in Tango 3.x and later versions.
Apple Event Reference
If you need to know the exact Apple event codes, here is a list of all the events and parameters.